#ifndef QUEUE_REGION_H_
#define QUEUE_REGION_H_

// INCLUDES //
#include "region.h"
#include "alignment_region.h"
#include "image_manager.h"
#include "object.h"
//////////////

// CONSTANTS //
#define QUEUE_CONTENT_SPACING	5
#define MAX_QUEUE_SIZE			12
///////////////

/**
* A region that represents the puzzle queue.
* 
* @author dfoelber
**/
class QueueRegion : public Region
{
public:
	struct PuzzlePair
	{
	public:
		Object* first;
		Object* second;
	};
	
public:
	/**
	* Constructor
	**/
	QueueRegion();
	
	/**
	* Destructor
	**/
	virtual ~QueueRegion();
	
	/**
	* Sets the alignment region.
	* 
	* @param region The alignment region
	**/
	void SetAlignmentRegion(AlignmentRegion* region) { alignmentRegion = region; }
	
	/**
	* Initializes the region, filling the queue.
	**/
	void Initialize();
	
	/**
	* Notify the region of an event.
	* 
	* Overridden from Region.
	* 
	* @param event The event that happened
	* @return If the region used the event
	**/
	virtual bool ProcessEvent( SDL_Event event );
	
	/**
	* Notifies of time passing.
	* 
	* Overridden from Region.
	* 
	* @param The amount of time, in milliseconds, that passed since the last call
	**/
	virtual void TimePassed( int ms );
	
	/**
	* Renders the objects on the background
	* 
	* Overridden from Region.
	**/
	virtual void Render();
	
	/**
	* Gets the top pair of gems in the queue.
	* 
	* @return The top pair of gems
	**/
	PuzzlePair* GetTopPair();
	
	/**
	* Dequeues the top pair of gems and queues another pair.
	**/
	void Dequeue();
	
	/**
	* Returns the queue.
	* 
	* @return The queue
	**/
	vector<PuzzlePair*>	GetQueue() { return queue; }
	
private:
	/** 
	* Calculates and returns the next gem to spawn.
	* 
	* @return The next Id (defined in Object.h)
	**/
	int CalculateNextGem();
	
	/** 
	* Translates an object Id to an image Id
	* 
	* @param Id The object Id
	* @return The image Id (defined in ImageManager.h)
	**/
	XYNE_IMAGE TranslateToImageId(int Id);

	/**
	* Queues a pair of gems.
	**/
	void Queue();
	
private:
	/// The queue of cards to be animated
	vector<PuzzlePair*>		queue;
	/// The alignment region for alignment values
	AlignmentRegion*		alignmentRegion;
};

#endif /*QUEUE_REGION_H_*/
